package citools

import (
	"fmt"
	"gitee.com/zhongguo168a/gocodes/myx/logx"
	"regexp"
	"strings"
)

func RysncChange盘符(sourcePath string) string {
	strings.ReplaceAll(sourcePath, `/a/ig`, "")
	re := regexp.MustCompile(`^(\w):(.*)`)
	sourcePath = re.ReplaceAllString(sourcePath, `$1$2`)
	return "/cygdrive/" + sourcePath
}

func RsyncDir(sourcePath, targetPath string) {

	var cmdstr string
	cmdstr = fmt.Sprintf(`rsync -avr "%v" "%v"`,
		sourcePath,
		targetPath,
	)
	err := Command(cmdstr)
	if err != nil {
		logx.Error(err)
	}
}

func RsyncFile(sourcePath, targetPath string) {

	var cmdstr string
	cmdstr = fmt.Sprintf(`rsync -avr "%v" "%v"`,
		sourcePath,
		targetPath,
	)
	err := Command(cmdstr)
	if err != nil {
		logx.Error(err)
	}
}
